//NJG C.2
#include "Store_menu.h"
#include <algorithm>
#include "Graph.h"
#include "Window.h"
using namespace std;
using namespace Store;

GraphingNJG::GraphingNJG( ) { };

extern Store_menu m;

vector<double> GraphingNJG::graph_display(){
	
	vector<Cart>cart = m.carts;
	vector<Product>products=m.prods;
	vector<Cart_item>items=m.cart_items;
	vector<double>total(12);
	double prod_total(0);
	for (int i(0);i<items.size();++i)
	{
		for(int k(0);k<products.size();++k)
		{
			if(items[i].getProdId()==products[k].getProdId())
			{
				prod_total=items[i].getProdQty()*products[k].getProdPrice();
				for (int j(0);j<cart.size(); ++j)
				{
					if (items[i].getCartId()==cart[j].getCartId()) 
					{
					total[cart[j].getPurchaseDate().month()-1]+=prod_total; //adding product total to the totals vector at [month-1]
					}
				}
			}
		}
	}
	return total;
}
		
	